package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.CarFileDao;
import cn.topevery.garden.entity.po.CarFile;
import cn.topevery.garden.entity.query.CarFileQuery;
import cn.topevery.garden.entity.vo.CarFileVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 *
 * @author code-generate
 * @date 2021-12-16
 */
@Service
public class CarFileLogic extends BaseLogic<CarFile> {
    @Autowired
    CarFileDao carFileDao;

    @Override
    public BaseEntityDao<CarFile, Integer> getDao() {
        return carFileDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<CarFileVO> listPage(CarFileQuery query) {
        return carFileDao.listPage(query);
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        carFileDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param carFileList 实体
     */
    public void saveOrUpdate(String userId,Integer pid, List<CarFile> carFileList){
        carFileDao.deleteById(pid);
        for(CarFile carFile : carFileList){
            carFile.setMainId(pid);
            carFileDao.saveOrUpdate(userId,carFile);
        }

    }

    /**
         * 根据自定义列值来获取对象
         */
    public CarFile getEntityByColumn(String key, String value) {
        return carFileDao.getEntityByColumn(key, value);
    }

    public List<CarFile> getListByPid(Integer pid){
        return carFileDao.getListByPid(pid);
    }

    void deleteById(Integer id){
        carFileDao.deleteById(id);
    }
}
